package com.ltcode.sys.infrastructure.persistence.converter;

import com.ltcode.sys.domain.model.SysRole;
import com.ltcode.sys.domain.model.SysUser;
import com.ltcode.sys.infrastructure.persistence.entity.SysRolePO;
import com.ltcode.sys.infrastructure.persistence.entity.SysUserPO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户对象转换器
 * 
 * @author ltcode
 * @since 2024-01-01
 */
public class SysRoleConverter {

    /**
     * PO转换为领域模型
     */
    public static SysRole toDomain(SysRolePO po) {
        if (po == null) {
            return null;
        }
        SysRole domain = new SysRole();
        BeanUtils.copyProperties(po, domain);
        return domain;
    }



    /**
     * PO列表转换为领域模型列表
     */
    public static List<SysRole> toDomainList(List<SysRolePO> poList) {
        if (poList == null || poList.isEmpty()) {
            return new ArrayList<>();
        }
        List<SysRole> domainList = new ArrayList<>();
        for (SysRolePO po : poList) {
            domainList.add(toDomain(po));
        }
        return domainList;
    }

}
